<template>
	<u-modal v-model="show" :show-cancel-button	="true"  @confirm="onConfirm"  confirm-color="#4D9D9F">
		<view class="tips-box">是否确认核销该订单？</view>
		<!-- 自定义 confirm 按钮 -->
		  <template #confirm-button>
				<button 
						class="confirm-btn"
			            open-type="getPhoneNumber"  
			            @getphonenumber="handleGetPhone">  
			      确认  
			    </button> 
		  </template>
	</u-modal>
</template>

<script>
	import {
		verificationConfirm
	} from '@/api/order';
	export default {
		props: {
			verifyCode: [Number, String]
		},
		data() {
			return {
				show: false
			};
		},
		methods: {
			open() {
				this.show = true
			},
			close() {
				this.show = false
			},
			async handleGetPhone(e){
				 // 用户取消授权
				  if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
					// uni.showToast({ title: "取消授权", icon: "none" });
					return false;
				  }
				  let mobileCode = e.detail.code;
				  console.log("mobileCode", mobileCode);
				const {
					verifyCode
				} = this;
				let params = {
					mobile_code: mobileCode,
					s: verifyCode
				}
				console.log('params', params)
				let res = await verificationConfirm(params);
		  
				if (res.code == 1) {
					this.close()
					this.$emit("refresh")
					this.$toast({
						title: res.msg
					});
				}
			},
			
			async onConfirm() {
				
		// 		const {
		// 			verifyCode
		// 		} = this;
		// 		let params = {
		// 			mobile_code: '',
		// 			s: verifyCode
		// 		}
		// 		let res = await verificationConfirm(params);
		
		// 		if (res.code == 1) {
		// 			this.close()
		// 			this.$emit("refresh")
		// 			this.$toast({
		// 				title: res.msg
		// 			});
		// 		}
			},
		}
	}
</script>

<style scoped>
.tips-box{
	padding: 30rpx 20rpx;
	font-size: 32rpx;
	color: #0C111A;
	text-align: center;
}
.confirm-btn{
	font-weight: bold;
	font-size: 32rpx;
	color: #4D9D9F;
	height: 100rpx;
	line-height: 100rpx;
}
</style>
